<?php
/**
 * Region Model
 *
 * @property Item
 */
class Region extends AppModel {
/**
 * Display field
 *
 * @var string
 */
	public $displayField = 'rname';

    public $hasMany = array(
        'Customer' => array(
            'className' => 'Customer',
            'foreignKey' => 'region_id',
            'dependent' => false,
            'conditions' => '',
            'fields' => '',
            'order' => '',
            'limit' => '',
            'offset' => '',
            'exclusive' => '',
            'finderQuery' => '',
            'counterQuery' => ''
        )
    );


    # Validation rules.
    var $validate = array(
        'rname' => array(
            'notNull' =>array(
    		   'rule' => 'notEmpty',
    		   'required' => true,
    		   'message' => 'The region Name must not be null and it is required',
    		   'last' => true
    		)
		)
	);

    
    function getById($id = null){
        $conditions = array(
           'Region.id' => $id,
           'Region.deleted' => 'n'
        );
        # fetch the specific data from the server and retrun it.
        return  $this->find('first', array('conditions' => $conditions, 'recursive' => -1));
    }
    
   
}
